package mhwi.cards.hunter;

import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAllEnemiesAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import mhwi.cards.HunterTemplateCard;
import mhwi.helper.ModHelper;

import static mhwi.constants.ResourcesConstant.*;

public class XinHaoDanCard extends HunterTemplateCard {
    private static final String CLASS_NAME = XinHaoDanCard.class.getSimpleName();
    public static final String ID = ModHelper.makeId(CLASS_NAME);
    private static final CardStrings CARD_STRINGS = CardCrawlGame.languagePack.getCardStrings(ID);
    private static final String NAME = CARD_STRINGS.NAME;
    private static final String IMG_PATH = ModHelper.makeFileName(PATH_IMG_CARDS_HUNTER, CLASS_NAME, EXTENSION_PNG);
    private static final String DESCRIPTION = CARD_STRINGS.DESCRIPTION;

    private static final int COST = 0;
    private static final CardType TYPE = CardType.SKILL;
    private static final CardRarity RARITY = CardRarity.BASIC;
    private static final CardTarget TARGET = CardTarget.ALL_ENEMY;

    public XinHaoDanCard() {
        super(ID, NAME, IMG_PATH, COST, DESCRIPTION, TYPE, RARITY, TARGET);
        this.tags.add(CardTags.STRIKE);
        this.baseDamage = 99999;
    }

    // 升级卡牌
    @Override
    public void upgrade() {
        if (!upgraded) {
            upgradeName();
            this.rawDescription = CARD_STRINGS.UPGRADE_DESCRIPTION;
            initializeDescription();
        }
    }

    // 使用卡牌
    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        AbstractDungeon.actionManager.addToTop(new DamageAllEnemiesAction(p, this.damage, DamageInfo.DamageType.NORMAL, AbstractGameAction.AttackEffect.SLASH_HEAVY));
        // 从主卡组永久移除
        AbstractDungeon.player.masterDeck.removeCard(this.cardID);
        // 标记为消耗（防止当前战斗重复使用）
        this.exhaust = true;
    }

    @Override
    public boolean canUse(AbstractPlayer p, AbstractMonster m) {
        if (!upgraded) {
            return p.hand.size() <= 1;
        } else {
            return true;
        }
    }
}